package com.leyou.item.controller;

import com.leyou.item.service.GoodsService;
import com.leyou.item.vo.SpuVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @author linzx
 * @date 2020/3/25
 */
@RestController
@RequestMapping("goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;

    @PostMapping
    public ResponseEntity<Void> saveGoods(@RequestBody SpuVO spuVO) {
        goodsService.saveGoods(spuVO);
        return ResponseEntity.ok().build();
    }

    @PutMapping
    public ResponseEntity<Void> updateGoods(@RequestBody SpuVO spuVO) {
        goodsService.updateGoods(spuVO);
        return ResponseEntity.ok().build();
    }

    @DeleteMapping("{spuId}")
    public ResponseEntity<Void> deleteGoods(@PathVariable("spuId")Long spuId) {
        goodsService.deleteGoods(spuId);
        return ResponseEntity.ok().build();
    }

//    @PostMapping("stock/decrease")
//    public ResponseEntity<Void> decreaseStock(@RequestBody List<CartDTO> cartDTOS);


}
